home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / PowerLisp 2.01 / PowerLisp 2.01 ƒ / Documentation / PowerLisp Doc
Text File  |  1996-05-26  |  67KB  |  1,845 lines

  1.  
  2.                         PowerLisp
  3.             
  4.             Common Lisp Development Environment
  5.  
  6.                        Version 2.0
  7.  
  8.                      by Roger Corman
  9.  
  10.                       May 23, 1996
  11.  
  12.  
  13.  
  14.  
  15.             Copyright © 1996 Roger Corman
  16.                   All rights reserved.
  17.  
  18.  
  19.  
  20.                         Contents
  21.  
  22. Introduction                                 1
  23. Licensing                                     3
  24.     Registering Your Copy of PowerLisp         5
  25.     How To Reach Us                             5
  26. Quick Start Tutorial                         6
  27. Files in this Release                        10
  28.     Compiling the Libraries                    11
  29. Interactive Environment                        12
  30.     Preferences                                13
  31. PowerEdit Text Editor                        14
  32.     PowerLisp 2.0 Editor Enhancements        16
  33. PowerLisp Compiler                            17
  34.     68k Compiler                            17
  35.     PowerPC Compiler                        17
  36. PowerLisp Assembler                            19
  37. PowerLisp Disassembler                        20
  38. Linking and Debugging                        21
  39. Memory Usage                                22
  40. Operating System Issues                        23
  41. Common Lisp Implementation                    24
  42.     Data Types                                25
  43.     Scope and Extent                        26
  44.     Type Specifiers                            26
  45.     Program Structure                        26
  46.     Predicates                                26
  47.     Control Structure                        26
  48.     Declarations                            27
  49.     Symbols                                    27
  50.     Packages                                27
  51.     Numbers                                    27
  52.     Characters                                27
  53.     Sequences                                27
  54.     Lists                                    27
  55.     Hash Tables                                28
  56.     Arrays                                    28
  57.     Strings                                    28
  58.     Structures                                29
  59.     The Evaluator                            29
  60.     Streams                                    29
  61.     Input/Output                            29
  62.     File System Interface                    30
  63.     Errors                                    30
  64.     Miscellaneous Features                    30
  65.     Loop                                    31
  66.     Pretty Printing                            31
  67.     CLOS                                    32
  68.     Conditions                                33
  69.     Series                                    33
  70.     Non-standard Extensions                    34
  71. New Features                                36
  72.     New Features in PowerLisp 2.0            36
  73.     New Features in PowerLisp 1.2            36
  74. Troubleshooting                                38
  75.     PowerLisp Startup Process                38
  76.     What To Do If PowerLisp Will Not Run    39
  77. Notes                                        40
  78.  
  79.  
  80.  
  81.  
  82.  
  83. Introduction
  84.  
  85.  
  86. This document is intended to provide an introduction to 
  87. PowerLisp 2.0, a Common Lisp development environment for 
  88. the Macintosh. PowerLisp consists of a Common Lisp 
  89. interpreter, native-code 680x0 and PowerPC compilers, 680x0 
  90. and PowerPC macro assemblers, 680x0 and PowerPC 
  91. disassemblers, incremental linker and multi-window text editor. 
  92. It requires a Macintosh with at least a 68020 processor and 
  93. system 7.0 or later, or a Power Mac. About 3 megabytes of RAM 
  94. are required to run it, and to do much with it you need more like 
  95. 5 or 6 megabytes. Like any Common Lisp system, the more 
  96. memory the better.
  97.  
  98. PowerLisp has the ability to run in the background. While 
  99. executing a Common Lisp program, the user may switch to 
  100. another application as it continues to run.
  101.  
  102. PowerLisp 2.0 is a fat binary application, and will automatically 
  103. run in native mode on a Power Mac, as well as continuing to run 
  104. on 68k Macintoshes. PowerLisp 2.0 includes compiled libraries 
  105. for both 68k Mac and Power Mac, and a PowerPC native code 
  106. compiler and assembler are included.
  107.  
  108. New to PowerLisp 2.0 includes CLOS support, the Common 
  109. Lisp object-oriented programming system. A number of other 
  110. improvements and bug fixes have been included in PowerLisp 
  111. 2.0.
  112.  
  113. PowerLisp is extremely fast. All compiled PowerLisp functions 
  114. execute as native 680x0  or PowerPC instructions. The speed is 
  115. comparable to other fully compiled languages.
  116.  
  117. PowerLisp programs execute in the background, while you are 
  118. using the system. All editor functionality is fully available while 
  119. you are compiling or otherwise executing Common Lisp 
  120. programs. I do not know of another development environment 
  121. on the Macintosh that can do this. Of course, you can also use of 
  122. a different application while your programs execute.
  123.  
  124. PowerLisp 2.0 is being released as shareware. I expect to release 
  125. regular updates, which will include new features and bug fixes. 
  126. The frequency and scope of these will depend on the amount of 
  127. interest there is in the product. I encourage everyone who finds 
  128. this product useful to send me the shareware fee (see Licensing, 
  129. below) and register your copy. Even if you don't elect to register 
  130. it, I appreciate correspondence via e-mail or otherwise letting me 
  131. know what you think of it.
  132.  
  133. Thanks to Digital Press and Guy Steele Jr., Common Lisp 
  134. documentation is now available from within PowerLisp. A 
  135. hierarchical menu structure allows browsing of the full text of 
  136. Common Lisp, the Language 2nd Edition. This text is distributed 
  137. electronically along with PowerLisp. It is also hooked into the 
  138. Common Lisp documentation function.
  139.  
  140. Please check this product out. I believe it offers extraordinary 
  141. value for the price. The primary alternative for Lisp 
  142. programming, Macintosh Common Lisp from Digitool, is an 
  143. excellent product. PowerLisp cannot compete on features or 
  144. performance with Macintosh Common Lisp. It is, however, one 
  145. tenth the cost ($50 as opposed to $395). I feel there may be a 
  146. niche for a low-cost, small, easy-to-use product like this. Also, at 
  147. least for the time being, PowerLisp is the only PowerPC native 
  148. common lisp that I know of. If you are using a Power Mac, and 
  149. you like Lisp, you will want to take PowerLisp for a spin!
  150.  
  151. I enjoy programming with PowerLisp, and I hope you will too.
  152.  
  153.  
  154. Roger Corman
  155.  
  156.  
  157.  
  158.  
  159. Licensing
  160.  
  161.  
  162. PowerLisp is distributed as shareware. The author of PowerLisp 
  163. reserves the copyright to the executable application, as well as 
  164. the source code to the compiler, assembler and library functions. 
  165. A payment of $50 gives you the right to use one copy of 
  166. PowerLisp. If you find this program useful, please send a check 
  167. for this amount to the address below (under Registering Your 
  168. Copy of PowerLisp). If you are a teacher, and are interested in 
  169. using this for a class, the standard license fee is $50.00 + $10.00 
  170. per student using PowerLisp. The $50.00 fee covers one 
  171. permanent license, while the $10.00 fees are good for the 
  172. duration of the class only. Students who wish to continue using 
  173. PowerLisp may choose to register permanently at the student 
  174. rate of $30.00. Unlicensed copies of this system cannot be 
  175. legitimately used in a class setting otherwise.
  176.  
  177. We have spent a considerable amount of time developing this 
  178. program. We may elect to spend a lot more time on it, but only if 
  179. licensing fees received warrant it.
  180.  
  181. You may share this program with others. You may not 
  182. redistribute it for profit, nor make any changes to it, without 
  183. the permission of the author.
  184.  
  185. Note: All registered users of PowerLisp 1.01, 1.1 or 1.2 
  186. automatically are registered users of PowerLisp 2.0. Contact us 
  187. via e-mail or telephone (see Registering your copy of PowerLisp, 
  188. below) to obtain your product registration code if you have 
  189. registered and have not received your code by mail.
  190.  
  191.  
  192. PowerLisp 2.0
  193.  
  194. License Price:            $50.00 US
  195. Student Price:            $30.00 US
  196.  
  197. What You Get:
  198.  
  199. •    On receipt of your check, we will forward you any the 
  200. most up-to-date information we have regarding bugs, 
  201. new versions and features.  We will keep you informed 
  202. of new versions and features as they become available. If 
  203. possible, send an e-mail address, so you can be added to 
  204. the soon-to-be setup PowerLisp mailing list. We will also 
  205. supply you with a Product Registration Code which you 
  206. may use to register your installed copy. This will disable 
  207. the startup registration dialog.
  208.  
  209. •    If you send a list of requested additional features, we 
  210. will do our best to implement them as soon as possible. 
  211.  
  212. •    We will attempt to help with any problems you have 
  213. and answer questions. We can only offer limited phone 
  214. support. The preferred method of contacting us is via e-
  215. mail or US mail. We will answer all mail 
  216. communications as soon as possible.
  217.  
  218. •    If and when we decide to convert this to a commercial 
  219. version (non-shareware) licensed owners of the 
  220. shareware version will be guaranteed a special 
  221. arrangement. This would likely be a free or at-cost 
  222. license upgrade to the commercial version.
  223.  
  224.  
  225. Registering Your Copy of 
  226. PowerLisp
  227.  
  228. Send a check for $50.00 US (or $30 if you are a 
  229. student) to:
  230.  
  231. Roger Corman
  232. 2124 Cummings Drive
  233. Santa Rosa, CA 95404
  234. USA
  235.  
  236. You may contact us by mail to the above address, or via e-mail 
  237. or telephone (see below). Along with the fee, be sure to send 
  238. your address (and phone number if you don’t mind). Also we 
  239. would appreciate a mention of which version you have, what 
  240. your system is like, and any comments you have. A wish list of 
  241. product improvements would also be welcome. Also, if possible, 
  242. please send an e-mail address where you would like PowerLisp 
  243. update information to be sent.
  244.  
  245.  
  246. How To Reach Us
  247.  
  248. The PowerLisp web site is at:
  249.                         http://www.crl.com/~rgcorman
  250.  
  251. This site will contain the most up-to-date release of PowerLisp 
  252. and the most up-to-date information.
  253.  
  254.  
  255. America Online:            PowerLisp
  256.  
  257. Internet E-mail:        PowerLisp@aol.com
  258.                         rgcorman@crl.com
  259.  
  260. Telephone:                (707) 575-4024 
  261. (voice)
  262.                         (707)528-7477 (fax)
  263.  
  264.  
  265.  
  266.  
  267.  
  268. Quick Start Tutorial
  269.  
  270.  
  271. This section is intended to briefly lead you through writing, 
  272. running, compiling, and disassembling a small Common Lisp 
  273. program with PowerLisp.
  274.  
  275. 1.    Start PowerLisp by double-clicking the application 
  276. icon. 
  277. It will take a few seconds as it loads the standard 
  278. libraries. When it finishes, your worksheet will be 
  279. displayed, with the blinking text cursor. The message 
  280. “Ready for input” should appear in the status message 
  281. area at the top of the worksheet. You should regularly 
  282. watch the status bar while programming within the 
  283. Worksheet. It will often display messages regarding the 
  284. status of the Lisp evaluator.
  285.  
  286. 2.    Enter a PowerLisp expression. 
  287. Try typing: 
  288.  
  289.     (list-all-packages)
  290.  
  291. This command invokes the common lisp function which 
  292. returns the packages loaded in the system. To execute it, 
  293. press the Enter key (not the Return key). In PowerLisp, 
  294. the Return key is only used for editing—to enter a new 
  295. line into the text in the window. Only the Enter key 
  296. executes anything. In this case, the entire line of text that 
  297. the cursor is positioned on is read by the PowerLisp 
  298. system and executed.
  299.  
  300. Note that you may use <Command>-Return (hold down the 
  301. Command key while pressing Return) to simulate the 
  302. Enter key if you prefer. Some keyboards do not have an 
  303. Enter key, and so may require this method.
  304.  
  305. After pressing Enter , the PowerLisp interpreter will 
  306. output a list representing the packages loaded in the 
  307. system. All PowerLisp output is in bold-faced text. What 
  308. you type is in normal text.
  309.  
  310.  
  311. 3.    Create and execute a common lisp function. 
  312. Try typing:
  313.  
  314.     (defun print-column (x)
  315.         "Prints the elements of a list in a 
  316. column."
  317.         (dolist (i x) 
  318.             (print i)))
  319.  
  320.     While typing this function, use the Return key to end 
  321. each line. 
  322.  
  323. After the whole function has been entered, highlight the 
  324. entire expression by clicking to the left of the opening 
  325. parenthesis and dragging to the right of the ending 
  326. parenthesis. After the whole expression is highlighted 
  327. (all four lines) press Enter. The Lisp system will read 
  328. and execute the expression, and then return and display 
  329. the name of the defined function print-column.
  330.  
  331. Alternatively, since you are editing in Lisp mode, you 
  332. may leave your text cursor positioned immediately 
  333. following the last close parenthesis if the function 
  334. definition. You should notice that the entire function 
  335. definition is outlined. When you press Enter, the 
  336. outlined expression is first automatically highlighted 
  337. then executed.
  338.  
  339. 4.    Execute the function. 
  340. Type:
  341.  
  342.     (print-column '(see hear taste smell 
  343. touch))
  344.  
  345. The print-column function you defined will cause 
  346. the list elements to be printed vertically in the worksheet 
  347. (one element on each line). It is being executed by the 
  348. interpreter.
  349.  
  350. 5.    Get function documentation. 
  351. Type:
  352.  
  353.     (documentation 'print-column 'function)
  354.  
  355. The system will display documentation that you defined 
  356. for the function.
  357.  
  358. 6.    Compile the function. 
  359. Type:
  360.     
  361.     (compile 'print-column)
  362.  
  363. If this is the first time you have requested the compiler, 
  364. it may take a few seconds to load the compiler and 
  365. assembler. After loading the compiler, the system will 
  366. compile the function. 
  367.  
  368. If the function compiles correctly, the system will print 
  369. the name of the function.
  370.  
  371.  
  372. 7.    Execute the compiled function by repeating step 4 
  373. above. 
  374. It is not necessary to retype this line—just go to the 
  375. previous line, highlight it and press Enter. In 
  376. PowerLisp, you should never have to retype anything!
  377.  
  378. The system should respond as in step 4.
  379.  
  380. 8.    Disassemble the function. 
  381. Type and execute the following line:
  382.  
  383.     (disassemble 'print-column)
  384.  
  385. The system will display a dump of the machine 
  386. instructions which comprise the function print-
  387. column. You may or may not be interested in this. 
  388. Compiled PowerLisp functions always include code to 
  389. check for the correct number of arguments (in this case, 
  390. one).
  391.  
  392. 9.    Time the function. 
  393. You can invoke PowerLisp’s high-resolution timer by 
  394. executing the line:
  395.  
  396.     (time (print-column '(see hear taste smell 
  397. touch)))
  398.  
  399. The function will be executed as before, and will be 
  400. followed by a message regarding the amount of time 
  401. elapsed during execution. You may compare this against 
  402. the interpreted version by re-executing the function 
  403. definition from step 3 and executing the line above 
  404. again. You will see that as an interpreted function it 
  405. executes slower.
  406.  
  407. 10.    Save the function you have defined. 
  408. Select the New command from the File menu. Name the 
  409. new file print-column.lisp.
  410.  
  411. Select PowerLisp Worksheet from the Window menu to 
  412. return to the worksheet (or just click on its window). 
  413. Select the function definition (from step 3) by 
  414. highlighting the whole thing.
  415.  
  416. Execute the Copy command via the Edit menu or 
  417. pressing <Command>-C.
  418.  
  419. Select the file print-column.lisp from the 
  420. Window menu or by clicking on its window. 
  421.  
  422. Execute the Paste command via the Edit menu or 
  423. pressing <Command>-V.
  424.  
  425. The function definition should be displayed in the 
  426. print-column.lisp window.
  427.  
  428. Select Save from the File menu to save the file.
  429.  
  430.  
  431.  
  432. Important Notes
  433.  
  434. •    You may have any number of files open. As editor 
  435. memory gets filled up, temporary files may be created to 
  436. store copies of the files you are editing. This helps 
  437. prevent the number of files you have open from 
  438. affecting the amount of memory available to Lisp 
  439. programs.
  440.  
  441. •    There is no difference between the PowerLisp 
  442. Worksheet and any other file. Every open file may 
  443. act as a worksheet. Lisp output will, however, be 
  444. inserted into any file which you use as a worksheet.
  445.  
  446.     New to PowerLisp 2.0: The above statement is no longer 
  447. completely correct. By default, all Lisp output will now 
  448. go to the Worksheet regardless of the window in which 
  449. you executed the command. If you prefer the old 
  450. behavior, you may enable it by turning off the Output 
  451. Always Goes To Worksheet option in the Preferences 
  452. dialog.
  453.  
  454. •    If you are not using Lisp mode editing, you may enter 
  455. common lisp expressions either a line at a time, pressing 
  456. Enter after each line, or by entering a complete 
  457. expression and then executing the entire thing at once. 
  458. The latter is highly recommended. In the first case, if you 
  459. have not entered a complete Lisp expression (perhaps 
  460. not closed a list), you will see a prompt containing the 
  461. number of open left parentheses in the message area at 
  462. the top of the editor window.
  463.  
  464.  
  465.  
  466.  
  467. Files in this Release
  468.  
  469.  
  470. The application is called PowerLisp 2.0. Double click on it 
  471. to launch PowerLisp.
  472. The documentation is in a Microsoft Word format file 
  473. PowerLisp 2.0 Documentation. A folder in the 
  474. PowerLisp main folder is called Library. It contains libraries 
  475. that PowerLisp needs while running. These include the 
  476. following lisp source files:
  477.  
  478. cl.lisp                Portions of the PowerLisp standard library .
  479. assembler_68k.lisp    The PowerLisp 680x0 assembler.
  480. compiler_68k.lisp    The PowerLisp 680x0 compiler.
  481. assembler_PPC.lisp    The PowerLisp PowerPC assembler.
  482. compiler_PPC.lisp    The PowerLisp PowerPC compiler.
  483. loop.lisp            The Common Lisp Loop facility (MIT version).
  484. backquote.lisp        Optimized backquote facility (from CLTL2, Guy Steele).
  485. defpackage.lisp        The defpackage macro implementation.
  486. describe.lisp        A partial implementation of the describe function.
  487. format.lisp            Format function implementation.
  488. graphics.lisp        Some basic graphics routines (PowerLisp specific).
  489. structures.lisp        Defstruct macro implementation.
  490. documentation.lisp    Documentation function implementation.
  491. clos.lisp            Clos library (Closette implementation).
  492. random.lisp            Random implementation (CMU).
  493. startup.lisp        Run at startup, causes above libraries to load. 
  494.                     This can never be compiled. You may add 
  495.                     startup code to the end of this file if you wish.
  496.  
  497. Additionally, compiled versions of these may exist along with 
  498. these source files. They have the same name, with a .fasl 
  499. extension (68k binaries) or .ppcl (PowerPC binaries).
  500.  
  501. The Examples folder contains some PowerLisp source files 
  502. you may want to refer to for examples of PowerLisp functions. 
  503. The file eliza.lisp is a rough version of the Eliza program 
  504. from Peter Norvig’s book. The examples are admittedly sparse. I 
  505. intend to have some good example programs in future versions. 
  506. If you have written an interesting program with PowerLisp, and 
  507. you wouldn’t mind having it distributed with the releases, 
  508. please send it to me. The file closette-tests.lisp contains 
  509. code from Art of the Metaobject Protocol, by Gregor Kiczales, 
  510. Jim des Rivieres and Daniel G. Bobrow. It contains many 
  511. examples of using CLOS.
  512.  
  513. The PowerLisp Worksheet file is the file that normally 
  514. gets loaded as the worksheet when you launch PowerLisp. If you 
  515. remove or delete this file, a new one will automatically be 
  516. created when you restart PowerLisp.
  517.  
  518. Compiling the Libraries
  519.  
  520. Although compiled versions of the PowerLisp libraries should 
  521. have been included with your release, you may want to recreate 
  522. them yourself. 
  523.  
  524. A files compile-68k-libraries.lisp and 
  525. compile-PPC-libraries.lisp are included in the 
  526. Library folder with this release. Execute the appropriate file 
  527. to compile the libraries. Give yourself as much memory as 
  528. possible and be prepared to wait a while. If you like you can 
  529. switch to another application and let the libraries compile in the 
  530. background. Of course, you can recompile just a single library if 
  531. you wish, by using the Common Lisp compile-file 
  532. function.
  533.  
  534. PowerLisp 2.0 does not support cross-compilation i.e. you 
  535. cannot compile 68k libraries on a Power Mac or PPC libraries on 
  536. a 68k Macintosh. 
  537.  
  538. If compilation is successful, new versions of the libraries with a 
  539. .fasl (68k) or .ppcl (PPC) extensions should show up in 
  540. your Library sub-folder.
  541.  
  542.  
  543.  
  544.  
  545.  
  546. Interactive Environment
  547.  
  548.  
  549. PowerLisp is integrated with the PowerEdit text editor. The 
  550. environment provides a “worksheet” approach to Common Lisp 
  551. development. It is specifically modeled on the MPW 
  552. environment, and also resembled the approach used by the 
  553. Mathematica application.
  554.  
  555. Rather than having a window which emulates a console (e.g. the 
  556. “Listener” in Macintosh Common Lisp), the worksheet approach 
  557. does not emulate a console. Any number of text windows may 
  558. be open, and any Common Lisp code in any open window may 
  559. be executed at any time. The user typically enters a Common 
  560. Lisp function or expression, highlights the expression, then 
  561. presses the Enter key. Note that the Enter key is distinct from the 
  562. Return key on the Macintosh keyboard. The Return key is used 
  563. in the editor to insert a new line. It will not cause the PowerLisp 
  564. system to interpret any text.
  565.  
  566. Note:     You may use <Command>-Return (hold down the 
  567. Command key while pressing Return) to simulate the Enter key if 
  568. you prefer. Some keyboards do not have an Enter key, and so 
  569. may require this method.
  570.  
  571. For convenience, if no text is highlighted, the entire line of text 
  572. that the text cursor is on will be interpreted whenever the Enter 
  573. key is pressed. This allows for a usage model which is similar to 
  574. a console (i.e. type a line, press Enter, type another line, press 
  575. Enter). Like most Lisp consoles, until a Lisp expression is 
  576. completely entered, no evaluation takes place and no output is 
  577. produced. If a Lisp expression is only partially completed, the 
  578. message area will display the message “Ready for 
  579. input.” followed by the number of open left parentheses. This 
  580. indicates that you are in the middle of executing an expression.
  581.  
  582. Pressing Enter after each line (partial expression input) should 
  583. not be used when you are in the editor’s Lisp mode, because 
  584. Lisp mode will sometimes cause more than just the current line 
  585. to be executed.
  586.  
  587. After an entire Common Lisp expression is read, it is interpreted, 
  588. and the resulting value is output at the line immediately 
  589. following the line that the text cursor is on.
  590.  
  591. New to PowerLisp 2.0: The above statement is no longer 
  592. completely correct. By default, all Lisp output will now go to the 
  593. Worksheet regardless of the window in which you executed the 
  594. command. If you prefer the old behavior, you may enable it by 
  595. turning off the Output Always Goes To Worksheet option in 
  596. the Preferences dialog.
  597.  
  598. Since Common Lisp code can be entered from anywhere in any 
  599. window, a prompt is not very useful. Output prompts also tend 
  600. to get in the way of entering the next expression, as they can 
  601. inadvertently get sent back as part of the next expression. 
  602. Therefore, by default, PowerLisp has no prompt. 
  603.  
  604. The worksheet approach allows you to very easily edit, execute, 
  605. re-edit, and re-execute expressions without unnecessary typing. I 
  606. think you will come to appreciate it as much as  I do.
  607.  
  608. The front-most edit window contains a status line. This area, 
  609. under the popup menus, is used by the system to display 
  610. messages about what it is doing. Unless the status line reads 
  611. “Ready for input”, you should not attempt to execute a 
  612. Common Lisp expression.
  613.  
  614. When a Common Lisp expression is being executed, you may 
  615. execute editor commands, and otherwise edit files. You may also 
  616. switch to another application. In this case, the Common Lisp 
  617. processing will continue in the background. This is useful, for 
  618. example, during a long compile. If you attempt to edit a file 
  619. (with PowerEdit, the PowerLisp editor), any text output by the 
  620. Common Lisp program will be directed to what was the current 
  621. text insertion point at the time the Enter key was pressed (to 
  622. begin the execution). I think this is generally what you want. If 
  623. you are editing the same file in which the expression was 
  624. executed, however, the PowerLisp output will reset the insertion 
  625. point whenever it outputs text. If you are going to edit files, you 
  626. probably should avoid editing the same file you are using to 
  627. execute Common Lisp code.
  628.  
  629.  
  630. Preferences
  631.  
  632. The amount of time PowerLisp spends executing Common Lisp 
  633. programs vs. the amount of time given up to background and 
  634. editing tasks is now controllable from the Preferences dialog. By 
  635. selecting Most Cooperative, background tasks will run the 
  636. smoothest, but Lisp programs may run slower. On older Macs, 
  637. or Macs with a lot of extensions, performance of Lisp programs 
  638. may be unacceptable. Least cooperative will give the least time 
  639. to background and editing tasks, allowing Lisp programs to run 
  640. the fastest. Background tasks will only get called once a second, 
  641. which may not be acceptable. The default setting is in the middle 
  642. between these extremes.
  643.  
  644. By default, all Lisp output will now go to the Worksheet 
  645. regardless of the window in which you executed the command. 
  646. If you prefer the old behavior, you may enable it by turning off 
  647. the Output Always Goes To Worksheet option in the 
  648. Preferences dialog.
  649.  
  650. Preferences setting must be explicitly saved, via the Save button 
  651. on the Preferences dialog, or they will revert back to their 
  652. original settings next time you run PowerLisp.
  653.  
  654.  
  655.  
  656.  
  657. PowerEdit Text Editor
  658.  
  659.  
  660. The PowerEdit text editor does not use TextEdit (the built in text 
  661. editor in the Macintosh ROM). It therefore is not restricted to 
  662. text files of 32 kilobytes or less. In fact, it can easily handle text 
  663. files over a megabyte in size. PowerEdit does not need to keep 
  664. the whole file in memory (any unmodified portions are left on 
  665. disk). 
  666.  
  667. PowerEdit, unlike TextEdit, correctly handles tabs. Tabs can be 
  668. set to 1, 4 or 8 spaces for the document. Other tab settings can be 
  669. added by using ResEdit to modify the Tabs popup menu 
  670. resource. Each text window gets its own tab setting. Tabs get 
  671. saved in the resource fork of the file, so that when the file is 
  672. reopened the editor will remember the most recent setting.
  673.  
  674. The PowerEdit functions should be self-explanatory. Features 
  675. include Undo, Find, Replace, Copy, Cut, Paste, Select All, and 
  676. Print. The Print feature is currently pretty rough. It doesn’t print 
  677. anything except the text of the file (no fancy formatting).
  678.  
  679. The Window menu maintains a list of all open text files. You can 
  680. use it to navigate between files when you have a lot of files open.
  681.  
  682. Scrolling
  683. PowerEdit uses an improved (slightly different) way of scrolling 
  684. than most Macintosh text editors. While you drag the scrollbar 
  685. thumb, the file scrolls. Normally, in other editors, the text 
  686. window does not scroll until after you release the thumb. I 
  687. worked hard to get this scrolling to work this way, and am very 
  688. pleased with the result. The only downside I can see is that it 
  689. may be a bit sluggish on slower Macs. I plan to have an option to 
  690. revert to “normal” scrollbar behavior in a future version.
  691.  
  692. Font and Size Pulldowns
  693. Each text window may have a different font and character size 
  694. associated with it. This information is not currently saved with 
  695. the file. The editor uses fractional widths internally to support 
  696. non-monospaced font editing. Typically monospaced fonts work 
  697. best for programming, however. The default font is Monaco, 9 
  698. pt. The font and font size selected are “remembered” by 
  699. information in the resource fork of  the file.
  700.  
  701. Document Preferences
  702. A resource of type ‘MPSR’ is added to the resource fork of any 
  703. text file which is created or viewed by PowerEdit. It contains the 
  704. user settings for the window position and size, the tab setting, 
  705. and the font and font size. It is compatible with the method that 
  706. MPW uses to save this information, so that it is convenient to 
  707. alternate between PowerEdit and MPW.
  708.  
  709.  
  710. Common Lisp Support in PowerEdit 
  711.  
  712. PowerEdit includes some features which make it particularly 
  713. useful for Common Lisp programming. For one thing, all 
  714. PowerLisp interpreter output (which is sent to standard output) 
  715. is printed in a bold version of the font you have selected. This 
  716. serves to distinguish between your input and the interpreter’s 
  717. output. The editor stores and remembers text style information. 
  718. The PowerLisp system ignores this information, however. All 
  719. text, bold or otherwise, looks the same to the interpreter.
  720.  
  721. An additional Lisp support feature involves the highlighting of 
  722. parenthesized expressions. If the window is in Lisp Mode, and 
  723. the text cursor is next to a parenthesized expression (a left or a 
  724. right parenthesis which is balanced) the entire expression is 
  725. highlighted by an outline. This is difficult to explain but 
  726. relatively easy to demonstrate. Just turn on Lisp Mode from the 
  727. popup menu, and enter a Common Lisp expression with several 
  728. levels of parentheses.
  729.  
  730. Lisp Mode is automatically turned on by the editor for any file 
  731. with a .lisp extension on the filename. You can explicitly turn 
  732. it on or off any time from the popup menu. 
  733.  
  734. In Lisp Mode, when a parenthesized Lisp expression is outlined, 
  735. pressing Enter will execute the entire expression, rather than just 
  736. the current line. To make it obvious, the whole expression gets 
  737. highlighted for a fraction of a second before executing it.
  738.  
  739. When the cursor is placed next to a lisp expression (highlighting 
  740. it), double clicking will select the entire expression, which is very 
  741. useful for cutting and pasting lisp expressions.
  742.  
  743. Line Wrap Mode
  744.  
  745. Line Wrap mode works much better in 2.0 than it did in any 
  746. previous version but still has some bugs that show up when 
  747. editing text. It is also rather slow on certain machines. You may 
  748. turn on this mode, via a checkbox to the left of the status line. I 
  749. find it occasionally useful to turn this mode on when browsing 
  750. unformatted Lisp output (which may otherwise produce vary 
  751. long lines). Line Wrap mode is now compatible with Lisp mode 
  752. (unlike with previous versions).
  753.  
  754. Formatting
  755.  
  756. When you save a file which has bold or italicized text in it, the 
  757. text attributes get stored in a resource of the file. This causes the 
  758. bold text to be bold when you later load the file (it saves this 
  759. attribute). You may use the edit menu commands Bold, Italics 
  760. and Plain to control the text attributes of text in a file. These 
  761. attributes are entirely ignored by the Lisp interpreter.
  762.  
  763. Lisp Mode
  764.  
  765. In the Lisp mode of the editor, when a parenthesized Lisp 
  766. expression is outlined, pressing Enter will execute the entire 
  767. expression, rather than just the current line. To make it obvious, 
  768. the whole expression gets highlighted for a fraction of a second 
  769. before executing it.
  770.  
  771. When the cursor is placed next to a lisp expression (highlighting 
  772. it), double clicking will select the entire expression, which is very 
  773. useful for cutting and pasting lisp expressions.
  774.  
  775.  
  776. PowerLisp 2.0 Editor 
  777. Enhancements
  778.  
  779. •    Lisp output goes to the Worksheet by default, regardless 
  780. of which window you execute a lisp expression from.
  781.  
  782. •     The amount of memory allocated to the editor was 
  783. increased in PowerLisp 2.0, which makes editing large 
  784. files a little smoother.
  785.  
  786. •     A bug that showed up on the display when dragging to 
  787. off the right or left side of the window (invoking auto-
  788. scrolling) has been fixed.
  789.  
  790. •     Several bugs relating to using Lisp mode and line wrap 
  791. mode together have been fixed. A few screen anomalies 
  792. (such as vertical bars) will still show up occasionally in 
  793. line wrap mode, however.
  794.  
  795.  
  796. Lisp mode has been improved. As several of you noted, it seems 
  797. logical that when a Lisp expression is outlined, pressing Enter 
  798. should execute the entire expression, rather than just the current 
  799. line. I have implemented this. To make it obvious, the whole 
  800. expression gets highlighted for a fraction of a second before 
  801. executing it.
  802.  
  803. Another problem several people had was getting buried in open 
  804. parentheses. When you are entering expressions, and have not 
  805. closed enough levels of parentheses, the system seems frozen. To 
  806. make it clearer, the editor now shows the number of open 
  807. parentheses in the message bar. I think this helps.
  808.  
  809. When you save a file which has bold or italicized text in it, the 
  810. text attributes get stored in a resource of the file. This causes the 
  811. bold text to be bold when you later load the file (it saves this 
  812. attribute). You may use the edit menu commands Bold, Italics 
  813. and Plain to control the text attributes of text in a file. These 
  814. attributes are entirely ignored by the Lisp interpreter.
  815.  
  816.  
  817.  
  818.  
  819.  
  820. PowerLisp Compiler
  821.  
  822.  
  823. 68k Compiler
  824. The PowerLisp 68k compiler is a full 680x0 native code compiler. 
  825. This means that a function, once compiled, executes as direct 
  826. machine instructions. This allows the compiled lisp functions to 
  827. execute very fast. It is distinct from the intermediate code that 
  828. some Lisp systems produce. 
  829.  
  830. The compiler can be invoked on a single function, with the 
  831. compile function, or on a source file with the compile-
  832. file function. The first time you call either of these functions, 
  833. the compiler and assembler modules are loaded into memory. 
  834. This can take from 5 to 20 seconds depending on your system. 
  835. After loading, compiling is quick. A function typically takes less 
  836. than one second to compile.
  837.  
  838. When the compile-file function is used, a binary file of 
  839. machine code is produced. This file is of type ‘FASL’ and 
  840. typically has the extension .fasl. Binary files are typically 
  841. about 3 times as large as the source files they originate from, but 
  842. that is only because of the relatively inefficient way that all the 
  843. symbol information is stored in the binary file. PowerLisp 1.1 
  844. compiled files are about 40% smaller than 1.01 compiled files 
  845. (and still compatible with 1.01 files). They need to store a lot of 
  846. symbol information so that all the addresses can automatically 
  847. be updated correctly when the file is loaded in another system or 
  848. at a later date. Once loaded, compiled code is relatively space 
  849. efficient. When compiled code segments are no longer needed, 
  850. the garbage collector will correctly discard them.
  851.  
  852. The entire compiler is written in Common Lisp. A couple of 
  853. support functions had to be added in C++ because there is no 
  854. support for packed arrays of short integers, but all the significant 
  855. stuff is in the file compiler.lisp which is included in this 
  856. release. The compiler directly generates 68000 assembler code, 
  857. which it then passes off to the assembler to create the function. I 
  858. could improve the compiler performance somewhat by 
  859. assembling as it goes, but I have found the intermediate step 
  860. useful for debugging the compiler.
  861.  
  862. The compiler generates code which generally behaves exactly 
  863. like interpreted code, only faster. I typically see a 5 to 30 times 
  864. speed improvement when I compile something. In terms of 
  865. debugging, there are some differences between interpreted and 
  866. compiled code. In at least one case, compiled code is more 
  867. correct than interpreted (in the case of returning multiple 
  868. values). Some special forms are not yet implemented in the 
  869. compiler.
  870.  
  871.  
  872. PowerPC Compiler
  873.  
  874. When running native, PowerLisp automatically loads and 
  875. executes the PowerPC compiler (compiler_ppc.lisp & 
  876. compiler.ppcl) in response to a compilation request. This 
  877. compiler generates PowerPC machine code which conforms to 
  878. Apple's PowerPC runtime architecture specification. When 
  879. PowerLisp is running native on a Power Mac, 68k compiled lisp 
  880. files (.fasl) cannot be used. Although theoretically possible to do 
  881. so, by invoking the 68k emulator via the mixed mode manager, 
  882. the time spent in mode switching would probably be 
  883. prohibitively expensive.
  884.  
  885. Compiled PowerPC code is stored in files with a .ppcl 
  886. extension. By running PowerLisp on a Power Mac, and 
  887. compiling your lisp code to native Power Mac code, you will get 
  888. the best performance possible from PowerLisp.
  889.  
  890. PowerLisp 2.0 Modifications
  891.  
  892. The special forms flet and labels are now supported by 
  893. the compiler. 
  894.  
  895.  
  896.  
  897.  
  898.  
  899. PowerLisp Assembler
  900.  
  901.  
  902. The assembler was designed primarily to service the compiler. It 
  903. is, however, useful in its own right. It could be used as a vehicle 
  904. for accessing toolbox calls and other system services which are 
  905. not otherwise provided. Little support for this is included, 
  906. however, in the current release. 
  907.  
  908.  
  909. 68k
  910. Not all 68000 instructions are implemented, although the most 
  911. common ones are. The complete source to the assembler is 
  912. included with this release, in the file 
  913. assembler_68k.lisp. The assembler is written in 
  914. Common Lisp, and all assembler instructions are implemented 
  915. as macros in the assembler package. These macros automatically 
  916. expand into the machine code for the instruction when expanded 
  917. by the assembler in the appropriate context. This simple design 
  918. allows the easy addition of assembler macros. Many sample 
  919. macros can be seen in the assembler source. 68000 instructions 
  920. which are not implemented could be added by anyone who 
  921. wanted to take the time. I plan to expand the assembler and add 
  922. a foreign function interface.
  923.  
  924.  
  925. PowerPC
  926. Not all PowerPC instructions are implemented, although the 
  927. most common ones are. The complete source to the assembler is 
  928. included with this release, in the file 
  929. assembler_ppc.lisp.  The above comments (regarding 
  930. the 68k assembler) apply to the PowerPC assembler as well.
  931.  
  932.  
  933.  
  934.  
  935. PowerLisp Disassembler
  936.  
  937.  
  938. The disassemble function can be used to disassemble a 
  939. compiled function to examine its machine code. It will 
  940. disassemble functions which have been compiled by the Lisp 
  941. compiler, as well as built-in functions which have been compiled 
  942. by the C++ compiler. It isn’t fancy, but it is pretty useful. For 
  943. compiled Common Lisp functions, the disassembler is good at 
  944. displaying the names of called functions (targets of jsr 
  945. instructions). Compiled C++ functions often call functions which 
  946. the disassembler does not know about, so you may get some 
  947. incorrect function names. Normally you will only be 
  948. disassembling compiled Common Lisp functions.
  949.  
  950. The PowerLisp 2.0 disassembler will disassemble PowerPC code 
  951. when running on a Power Mac, or 68k code when running on a 
  952. 68k Macintosh.
  953.  
  954.  
  955.  
  956.  
  957. Linking and Debugging
  958.  
  959.  
  960. PowerLisp features an incremental linker which immediately 
  961. link in functions when they are compiled or loaded. Whenever a 
  962. function is replaced by a new function, whether compiled or 
  963. interpreted, all compiled branches to that function are correctly 
  964. routed to the new function. This is done via a distributed jump 
  965. table which is managed by the linker. Interpreted functions have 
  966. a jump table entry which will cause a branch into the interpreter 
  967. whenever a compiled function tries to call them. The interpreter 
  968. can then, based on call stack information, determine which 
  969. function was intended, and then evaluate it. If that function is 
  970. later compiled, a direct jump to it replaces the interpreter branch.
  971.  
  972. Debugging facilities are rudimentary. Some non-standard 
  973. functions are included which will trace the evaluation call stack 
  974. or the compiled function call stack. Unfortunately there is not a 
  975. single integrated function which will trace both.
  976.  
  977. While a Common Lisp program is executing, the call stack may 
  978. in fact have an interpreted lisp function, which calls a compiled 
  979. lisp function, which calls a compiled C++ function, which calls 
  980. an interpreted Lisp function, ad nauseam. This situation is quite 
  981. common, in fact. Debugging is a little easier if all the functions 
  982. you are debugging are compiled, or all are interpreted.
  983.  
  984. Trace and untrace functions are useful for interpreted code. They 
  985. are not of much value for compiled code. I use the non-standard 
  986. functions address and exec-address a lot to get 
  987. addresses which I can then examine in MacsBug.
  988.  
  989. A function called error-stack is included to help with 
  990. debugging. If your program aborts with an error message, you 
  991. may immediately invoke this:
  992.  
  993. (error-stack)
  994.  
  995. This will print a processor dump of the top ten stack frames 
  996. when the error occurred. This works better for compiled-code 
  997. than for interpreted code, because all the functions on the 
  998. processor stack will be interpreter functions in interpreted mode 
  999. (as opposed to your functions). It still will print useful 
  1000. information, however.
  1001.  
  1002. To see the interpreter stack, you may use the function dump-
  1003. lisp-stack. This must be invoked prior to an error 
  1004. occurring, however. Typically you can put it into the code of an 
  1005. interpreted function. When that function executes, the call to 
  1006. dump-lisp-stack will cause the top interpreter stack 
  1007. frames to get displayed, along with the associated lexical 
  1008. environments.
  1009.  
  1010.  
  1011.  
  1012.  
  1013. Memory Usage
  1014.  
  1015.  
  1016. Like most Lisp systems, PowerLisp likes to have quite a bit of 
  1017. memory. Garbage collection will be invoked frequently if you 
  1018. are short on memory, and that will cause performance to suffer.
  1019.  
  1020. At startup, PowerLisp sets aside enough memory to hold the 
  1021. application’s code segments in memory, as well as some memory 
  1022. for operating system overhead such as windows, resources, etc. 
  1023. Approximately 300k bytes of RAM are set aside for the editor to 
  1024. hold text. About 25% of the remaining memory is given to the 
  1025. stack. This allows a large amount of recursion without 
  1026. overflowing the stack. The rest is allocated as a large non-
  1027. relocatable block which is then managed by the PowerLisp 
  1028. memory manager.
  1029.  
  1030. The PowerLisp memory manager allocates about 50% of the 
  1031. heap to Lisp nodes. These are each 10 bytes in size (12 bytes on 
  1032. Power Macs), and consist of two pointers and flag and type bits. 
  1033. They are used to store cons cells, integers, floating point 
  1034. numbers, ratios, and characters. Other Lisp data types require 
  1035. larger blocks. All larger items and variable sized memory blocks 
  1036. are allocated by the other 50% of the heap. This strategy has 
  1037. proven to provide good performance. Fixed size cons nodes can 
  1038. be allocated very quickly. The garbage collector only keeps track 
  1039. of these nodes, or objects which are referenced by these nodes.
  1040.  
  1041. In a typical scenario:
  1042.  
  1043. PowerLisp partition size:        4096K bytes (4 megabytes)
  1044. System use:                         600K
  1045. Editor heap:                     300K
  1046. Stack:                             800K
  1047. Nodes:                            1200K (around 125,000 nodes)
  1048. Variable sized heap objects:    1200K (used by Lisp system)
  1049.  
  1050. Variable sized heap objects include compiled Lisp code, vectors, 
  1051. arrays, text editor data structures, packages and hash tables.
  1052.  
  1053.  
  1054. Memory Requirements
  1055.  
  1056. PowerLisp 2.0 requires at least a 4  megabyte partition. However, 
  1057. 5 megabytes is a more reasonable minimum. If you want to use 
  1058. the compiler, you will need at least a 5 megabyte partition. A 
  1059. larger partition is recommended, or else you will wait on the 
  1060. garbage collector a lot while compiling. 6 megabytes is a good 
  1061. size for moderate projects.
  1062.  
  1063.  
  1064.  
  1065. Operating System Issues
  1066.  
  1067.  
  1068. PowerLisp runs only with Macintosh operating systems 7.0 or 
  1069. later. PowerLisp multitasks cooperatively with other 
  1070. applications, so that programs can continue running in the 
  1071. background while PowerLisp programs are executing. 
  1072. PowerLisp programs can also run in the background while you 
  1073. are running other applications.
  1074.  
  1075. PowerLisp supports the standard four Apple Events: Launch, 
  1076. Open, Print and Quit. It is therefore high-level event aware. It is 
  1077. 32-bit clean, and makes use of as much memory as you choose to 
  1078. give it. 
  1079.  
  1080. PowerLisp is fully compatible with system 7.5.
  1081.  
  1082.  
  1083.  
  1084.  
  1085. Common Lisp Implementation
  1086.  
  1087.  
  1088. The Common Lisp implementation in this release of PowerLisp 
  1089. is lacking in a number of ways, which I will detail below. As you 
  1090. probably are aware, Common Lisp consists of a huge number of 
  1091. functions and data types. Rather than wait a couple more years 
  1092. to release this, I have tried to include the most useful features of 
  1093. the language. As a very rough estimate, I believe this release 
  1094. implements about 95% of Common Lisp as specified in the first 
  1095. edition of  Guy Steele’s Common Lisp: The Language., 2nd 
  1096. edition. 
  1097.  
  1098. I would like to build a reference of what is included, because it 
  1099. would include a huge number of functions and features. Because 
  1100. of time constraints, however, I will have to base this document 
  1101. more on what is missing from Common Lisp: The Language. 
  1102. While a number of things are not currently implemented, it is 
  1103. still a very useful system. 
  1104.  
  1105. The following section of this document covers the PowerLisp 
  1106. language implementation, roughly in the order in which they are 
  1107. covered in Guy Steele’s Common Lisp: The Language, Second 
  1108. Edition.
  1109.  
  1110. In this document, I will refer to Guy Steele’s Common Lisp: The 
  1111. Language, the first edition, as CLTL1. The second edition of the 
  1112. reference will be referred to as CLTL2.
  1113.  
  1114. Data Types
  1115.  
  1116. Characters
  1117. Symbols
  1118. Lists
  1119. Functions
  1120. Text strings
  1121. Packages
  1122. Hash tables
  1123. Read tables 
  1124. Random States
  1125. These data types are all implemented according to the language 
  1126. specification.
  1127.  
  1128. Numbers    
  1129. Integers, floating-point and ratios are implemented. PowerLisp 
  1130. 1.1 includes  complex numbers and bignums (large integers). 
  1131. Integers are stored in 32 bits, floating-point in 64 bits and ratios 
  1132. consist of two integers. Only one size of floating point number is 
  1133. provided. Large integers may be any size up to your memory 
  1134. limitations.
  1135.  
  1136. Arrays
  1137. Generalized arrays, bit vectors and character strings are 
  1138. supported.
  1139. Bit vectors and generalized arrays may be multi-dimensional, up 
  1140. to 7 dimensions. Character strings may only be single-
  1141. dimensioned (vectors).
  1142. Arrays of specific types (packed arrays of integers, for example) 
  1143. are not supported, but this should largely be transparent to 
  1144. Common Lisp programs.
  1145.  
  1146. Streams
  1147. Streams are implemented, with a few limitations.
  1148.  
  1149. Pathnames
  1150. Pathnames are just text strings currently—no “system 
  1151. independent” path name object is supported. Pathname strings 
  1152. can represent full path names, or partial path names relative to 
  1153. the default directory. They must be in Macintosh format, which 
  1154. uses colons rather than slashes to separate directory names.
  1155.  
  1156. Examples of paths:
  1157.  
  1158. "VolumeName:My Directory:My File"     ; full path
  1159. "My File"                    ; in current 
  1160. directory
  1161. ":My Subdirectory:My File"        ; in 
  1162. subdirectory of current
  1163. "::MyFile"                    ; in parent 
  1164. directory (one level up)
  1165.  
  1166. Random States
  1167. The random number package is fully implemented using the 
  1168. CMU library. This results in much better randomness than the 
  1169. previous implementation. The random states are now readable.
  1170.  
  1171.  
  1172. Structures
  1173. Structures are implemented according to the language standard. 
  1174. Some of the
  1175. options are not supported yet, however. List-based structures are 
  1176. not supported. In PowerLisp 1.1 code which uses structures will 
  1177. compile correctly.
  1178.  
  1179. Objects
  1180. CLOS is now included with PowerLisp. See the section on CLOS 
  1181. for more information.
  1182.  
  1183.  
  1184. Scope and Extent
  1185.  
  1186. PowerLisp adheres to the Common Lisp specification.
  1187.  
  1188.  
  1189. Type Specifiers
  1190.  
  1191. The Common Lisp type system conforms to CLTL2. No 
  1192. optimizations are currently done based on type declarations.
  1193.  
  1194.  
  1195. Program Structure
  1196.  
  1197. This area of the language is more or less complete. This includes 
  1198. functions, both interpreted and compiled, special forms, macros 
  1199. (interpreted and compiled), special variables, constants, etc. All 
  1200. special forms are correctly recognized.
  1201.  
  1202. All defining constructs (defun, defmacro, defstruct, 
  1203. defconstant, etc.) allow the inclusion of a documentation 
  1204. string. This string gets stored on the property list of the symbol, 
  1205. and can be accessed as specified by the language.
  1206.  
  1207. Compiled and interpreted functions can be freely intermixed in 
  1208. the call stack, and compiled functions are incrementally linked 
  1209. into the system as soon as they are compiled or read.
  1210.  
  1211.  
  1212. Predicates
  1213.  
  1214. Implemented.
  1215.  
  1216.  
  1217. Control Structure
  1218.  
  1219. Most of this chapter is implemented, with a few exceptions. 
  1220. Compiler macros and the compiler-let form are not 
  1221. implemented. Some of the features which are new in CLTL2  are 
  1222. not implemented.
  1223.  
  1224.  
  1225. Declarations
  1226.  
  1227. Declarations are mostly allowed but ignored by PowerLisp. In 
  1228. future versions of the compiler, faster code generation should be 
  1229. possible by paying attention to declarations. Violations of 
  1230. declarations are also ignored.
  1231.  
  1232. In PowerLisp 1.1 and later, special declarations are 
  1233. significant, and are correctly interpreted and compiled.
  1234.  
  1235.  
  1236. Symbols
  1237.  
  1238. Implemented.
  1239.  
  1240.  
  1241. Packages
  1242.  
  1243. Implemented.
  1244.  
  1245. In PowerLisp 1.1 and later, defpackage and the remaining 
  1246. package functions and macros have been included. There may 
  1247. still be some problems with the way shadowing symbols are 
  1248. handled, and user interaction with the shadowing facility is not 
  1249. supported (load time querying to resolve ambiguities).
  1250.  
  1251.  
  1252. Numbers
  1253.  
  1254. PowerLisp includes most of the numeric functionality specified 
  1255. in CLTL2. Some math functions will give an error when they 
  1256. encounter a large integer or complex number. The byte are 
  1257. now implemented in PowerLisp 2.0. The boole function is not 
  1258. implemented.
  1259.  
  1260.  
  1261. Characters
  1262.  
  1263. All chars are standard-chars. 
  1264.  
  1265.  
  1266. Sequences
  1267.  
  1268. These functions are pretty complete. All sequence operations can 
  1269. be applied to lists, vectors, bit vectors and character strings.
  1270.  
  1271. Lists
  1272.  
  1273. Implemented.
  1274.  
  1275.  
  1276. Hash Tables
  1277.  
  1278. Implemented. Hash Tables are used internally by the package 
  1279. system.
  1280.  
  1281.  
  1282. Arrays
  1283.  
  1284. Partially implemented. Arrays can be up to seven dimensions. 
  1285. Some key arguments to make-array are not implemented.  
  1286. PowerLisp 2.0 has much improved array functionality over 
  1287. previous versions, and most array features.
  1288.  
  1289.  
  1290. Strings
  1291.  
  1292. Mostly implemented. A few of these functions need to be 
  1293. implemented still. 
  1294.  
  1295.  
  1296. Structures
  1297.  
  1298. Structures can be defined and are correctly added to the type 
  1299. system. Some key arguments to defstruct and some slot 
  1300. options are not implemented yet.  PowerLisp 2.0 handles 
  1301. structures much better, more efficiently and implements more of 
  1302. the standard functionality than did previous versions.
  1303.  
  1304.  
  1305. The Evaluator
  1306.  
  1307. This is the Common Lisp interpreter. Top level run-time loop 
  1308. features such as +, ++, +++ and *, **, *** are now 
  1309. implemented.
  1310.  
  1311.  
  1312. Streams
  1313.  
  1314. Partially implemented. This area is still a little weak and is a high 
  1315. priority for improvement. The most important features are there, 
  1316. however. PowerLisp 1.2 adds support for specification of read, 
  1317. write or read/write access when file streams are created with the 
  1318. open function.
  1319.  
  1320.  
  1321. Input/Output
  1322.  
  1323. The Lisp reader is implemented as specified, which is not easy in 
  1324. an event-driven environment! Read macros can be defined, and 
  1325. are used internally for many things (check out the standard 
  1326. library and compiler source code).
  1327.  
  1328. Options to the format function are partially implemented. 
  1329. This needs some work still. A number of other features described 
  1330. in this chapter are not yet implemented.
  1331.  
  1332. PowerLisp 2.0 supports more format options than previous 
  1333. versions.
  1334.  
  1335.  
  1336.  
  1337. File System Interface
  1338.  
  1339. As mentioned above, pathnames are just character strings 
  1340. currently. I intend to change this soon, so that a pathname object 
  1341. contains an FSSpec internally but can still be specified by a 
  1342. path string. Using strings for pathnames is compatible with 
  1343. Common Lisp.
  1344.  
  1345. Some Macintosh-specific functions are available:
  1346.  
  1347. (set-file-creator my-open-file "ROSA")
  1348. (set-file-type my-open-file "EPSF")
  1349.  
  1350. These functions can be used to set the type and creator of any 
  1351. open file. An error is signaled if you try to call these functions on 
  1352. other types of streams.
  1353.  
  1354. File wildcard specifiers are not yet supported.
  1355.  
  1356.  
  1357. Errors
  1358.  
  1359. Errors are implemented as exceptions (as thrown by the throw 
  1360. special form). They are typically caught at the top level. 
  1361. Continuable errors are not yet implemented (for want of a 
  1362. debugger).
  1363.  
  1364. In general, all Lisp functions, both compiled and interpreted, 
  1365. signal errors whenever the wrong number or type of arguments 
  1366. is passed to them. 
  1367.  
  1368.  
  1369. Miscellaneous Features
  1370.  
  1371. Compiler 
  1372. The compiler is covered in a separate section. 
  1373.  
  1374. Documentation
  1375. The documentation facility is fully implemented.
  1376.  
  1377. Debugging tools
  1378. While compiled and interpreted functions peacefully coexist at 
  1379. run-time, their behavior as regards debugging is significant. The 
  1380. macros trace and untrace  are implemented for 
  1381. interpreted, but not compiled code. That is, you can compile a 
  1382. function which calls trace , but only the interpreted function 
  1383. calls will actually be traced.
  1384.  
  1385. The step function is not implemented. There is no real 
  1386. interactive debugger. This should be improved in a future 
  1387. release.
  1388.  
  1389. The time macro is implemented, and uses the Mac’s Time 
  1390. Manager to produce microsecond timings accurate to about 20 
  1391. microseconds. This is very useful for performance tuning.
  1392.   
  1393. The describe function is only partially implemented 
  1394. (symbols are well supported). I intend to improve it.
  1395.  
  1396. The inspect function is not implemented yet.
  1397.  
  1398. The room function can be used to determine how much 
  1399. memory is available. See below for more information about 
  1400. memory usage. Another function gc invokes the garbage 
  1401. collector. Usually you should call it before calling room to get 
  1402. an accurate result.
  1403.  
  1404. The ed function is implemented for editing files: 
  1405.  
  1406. (ed filename)
  1407.  
  1408. causes the PowerEdit editor to open the file filename for 
  1409. editing. This is identical to using the Open command from the 
  1410. editor.
  1411.  
  1412. The functions dribble and apropos are not implemented.
  1413.  
  1414. Environmental Inquiries
  1415.  
  1416. These are not yet implemented.
  1417.  
  1418.  
  1419. Loop
  1420.  
  1421. The complete Loop facility is provided courtesy of the publicly 
  1422. available source code from MIT. This has been tested and run 
  1423. both in interpreted and compiled mode and seems to work fine. 
  1424. It has not been tested thoroughly, however.
  1425.  
  1426. Loop macros tend to expand into huge Common Lisp 
  1427. expressions, which execute slowly in interpreted mode but 
  1428. compile into pretty tight, fast code. It is like a language unto 
  1429. itself, and rather interesting.
  1430.  
  1431. The first time the system encounters a loop macro, it loads the 
  1432. loop package. This takes a few seconds. Subsequent uses of 
  1433. loop will not demonstrate this delay.
  1434.  
  1435.  
  1436. Pretty Printing
  1437.  
  1438. A simple pretty printing function is now included with 
  1439. PowerLisp. The fully cusomizable pretty printing functionality 
  1440. proposed in CLTL2 is not implemented.
  1441.  
  1442.  
  1443.  
  1444.  
  1445. CLOS
  1446.  
  1447. This had been added in PowerLisp 2.0. It is based on the Closette 
  1448. implementation in the book The Art of the Metaobject Protocol 
  1449. by Gregor Kiczales, Jim des Rivières, and Daniel G. Bobrow. The 
  1450. source to this implementation is included (in the file 
  1451. clos.lisp in the library folder). This implementation of 
  1452. CLOS is a subset of the full CLOS specification (as described in 
  1453. CLTL2). The following limitations apply (according to Chapter 1, 
  1454. section 1.1 of the book):
  1455.  
  1456. All the essential features of full CLOS are included: 
  1457. classes, which inherit structure and behavior from one or 
  1458. more classes, instances of classes, which are created, 
  1459. initialized and manipulated; generic functions, whose 
  1460. behavior depends on the classes of the arguments 
  1461. supplied to them; and methods which define the class-
  1462. specific behavior and operations of generic functions. 
  1463. The major restrictions of the simplified dialect include:
  1464.  
  1465. No class redefinition. Full CLOS allows the definition of 
  1466. a class to be changed; the changes are propagated to its 
  1467. subclasses and to extant instances. The subset does not 
  1468. allow classes to be redefined.
  1469.  
  1470. No method redefinition. Full CLOS allows methods to 
  1471. be redefined, with the new definition completely 
  1472. replacing the old one. The subset does not allow 
  1473. methods to be redefined.
  1474.  
  1475. No forward-referenced superclasses. Full CLOS allows 
  1476. classes to be references before they are defined. One 
  1477. class can be defined in terms of another before the 
  1478. second has been defined. These forward references are 
  1479. not permitted in the subset.
  1480.  
  1481. Explicit generic function definitions. Full CLOS allows 
  1482. the definition of a generic function to be inferred from 
  1483. the method definitions. The subset requires that a 
  1484. generic function be explicitly introduced with a 
  1485. defgeneric form before any methods are defined on it.
  1486.  
  1487. Standard method combination only. Full CLOS 
  1488. provides a powerful mechanism for user control of 
  1489. method combination. The subset defines only simple 
  1490. "demon" combination (primary, before- and after- 
  1491. methods).
  1492.  
  1493. No eql specializers. Full CLOS allows methods to be 
  1494. specialized not only to classes, but also to individual 
  1495. objects. The subset restricts method specialization to 
  1496. classes.
  1497.  
  1498. No slots with :class allocation. Full CLOS supports slots 
  1499. allocated in each instance of a class, and slots which are 
  1500. shared across all of them. The subset defines only per-
  1501. instance slots.
  1502.  
  1503. Types and classes not fully integrated. Full CLOS 
  1504. closely integrates Common Lisp types and CLOS classes. 
  1505. It is possible to define methods specialized to primitive 
  1506. classes (e.g. symbol) and structure classes (defined with 
  1507. defstruct). The subset defines classes for the primitive 
  1508. Common Lisp types but not for structure classes.
  1509.  
  1510. Minimal syntactic sugar. A number of convenience 
  1511. macros and special forms are not included in the subset. 
  1512. These include with-slots, generic function, 
  1513. generic-flet and generic-labels.
  1514.  
  1515. The book is highly recommend if you want to work with CLOS. 
  1516. The file clos-tests.lisp, included with PowerLisp 2.0 in 
  1517. the examples folder, contains most of the code samples from the 
  1518. book, and is useful for seeing how CLOS works.
  1519.  
  1520.  
  1521. Conditions
  1522.  
  1523. Not implemented (CLTL2 feature).
  1524.  
  1525.  
  1526. Series
  1527.  
  1528. Not implemented (CLTL2 feature).
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535. Non-standard Extensions
  1536.  
  1537.  
  1538. Here are some non-standard functions and variables which are 
  1539. included in PowerLisp and which you may find useful.
  1540.  
  1541.  
  1542. *top-level*                        [variable]    
  1543. This should normally be bound to the top-level read-eval-print 
  1544. loop.
  1545.  
  1546. address object                    [function]  
  1547. Returns the machine address of  the lisp object that is its 
  1548. argument.
  1549.  
  1550. exec-address compiled-function    [function]  
  1551. Returns the machine execution address of a compiled function. If 
  1552. a symbol which has a compiled-function associated with it is 
  1553. passed, that symbol’s jump table address (maintained by the 
  1554. incremental linker) is returned. Note that this is different from 
  1555. the address of the function, but normally just represents a jump 
  1556. instruction to the other address. This function is useful for 
  1557. debugging compiled code (in combination with a debugger like 
  1558. MacsBug).
  1559.  
  1560. function-definition function     [function]
  1561. Returns the lambda expression of an interpreted function. This 
  1562. function is superseded by the ANSI Common Lisp function 
  1563. function-lambda-expression, which is implemented 
  1564. in PowerLisp 1.1 and later, and returns the lambda expression as 
  1565. the first of three return values.
  1566.  
  1567. gc                                [function]
  1568. Explicitly invokes the garbage collector. This is more or less a 
  1569. standard language extension, but is not required by the 
  1570. standard. Use it before calling the room function for a more 
  1571. accurate estimate of space remaining.
  1572.  
  1573. package-hash-table package         [function]
  1574. Returns the hash table used by the passed package. This is 
  1575. sometimes useful.
  1576.  
  1577. print-function     interpreted-function [function]
  1578. Prints the passed function.
  1579.  
  1580. hash-table-misses hash-table    [function]
  1581. Provides statistics on hash-table effectiveness. Returns the 
  1582. number of times a hash-table lookup attempt has “missed” 
  1583. (failed).
  1584.  
  1585. hash-table-hits hash-table        [function]
  1586. Provides statistics on hash-table effectiveness. Returns the 
  1587. number of times a hash-table lookup attempt has “hit” 
  1588. (succeeded).
  1589.  
  1590. set-file-type file-stream type-string [function]
  1591. Sets the Finder type for the open file. Signals an error if a stream 
  1592. which is not a file is passed to it.
  1593.  
  1594. Example:
  1595. (setq f (open "myfile"))
  1596. (set-file-type f "EPSF") ; sets the file's 
  1597. type to 'EPSF'
  1598.  
  1599. set-file-creator file-stream creator-string    [function]
  1600. Sets the Finder creator for the open file. Signals an error if a 
  1601. stream which is not a file is passed to it.
  1602.  
  1603. Example:
  1604. (setq f (open "myfile"))
  1605. (set-file-creator f "ROSA")    ; set the 
  1606. file's creator to 'ROSA'
  1607.  
  1608. dump-lisp-stack                    [function]
  1609. This function prints a trace of the evaluator stack. It will only 
  1610. include information on evaluated function calls (not compiled 
  1611. functions).
  1612.  
  1613. %stack-trace                    [function]
  1614. This function returns a list of information on each processor 
  1615. stack frame. This is useful when debugging compiled functions. 
  1616. Evaluated function calls will show up as calls to the interpreter.
  1617.  
  1618. *stack-trace*                    [variable]
  1619. After any error, this global variable is automatically left bound to 
  1620. a list of stack frames that were in effect at the time of the error (as 
  1621. obtained with %stack-trace). This is very useful. Use the 
  1622. expression:
  1623.  
  1624. (error-stack)
  1625.  
  1626. after an error to see the stack trace.
  1627.  
  1628. error-stack                        [function]
  1629. This function may be used to print a dump of the processor stack 
  1630. state at the time the last error was encountered. This function can 
  1631. be used instead of the expression listed above.
  1632.  
  1633.  
  1634.  
  1635.  
  1636. New Features
  1637.  
  1638. New Features in PowerLisp 2.0
  1639.  
  1640. The biggest new feature in PowerLisp 2.0 is the addition of 
  1641. CLOS support. See the section on CLOS for details.
  1642.  
  1643. A Preferences dialog has been added. It lets you control how 
  1644. much time is given to background processes while Lisp 
  1645. programs are running. It also lets you choose between having 
  1646. output all go to the Worksheet vs. output will go to the window 
  1647. that last executed a Lisp command.
  1648.  
  1649. A registration screen has been added at startup. If you have 
  1650. registered, you can disable it by entering your name and product 
  1651. registration code in the Registration dialog. Contact Roger 
  1652. Corman to receive your code if you have already registered.
  1653.  
  1654. In PowerLisp 2.0, structures, arrays and strings are all stored 
  1655. more efficiently. Arrays and strings are more consistent and 
  1656. more closely adhere to the Common Lisp standard. 
  1657.  
  1658. The Common Lisp variables +,  ++, *, **, etc. are now properly 
  1659. bound during top loop execution as specified in the Common 
  1660. Lisp standard.
  1661.  
  1662. A number of other Common Lisp functions which were missing 
  1663. are now implemented (I am sorry to not be more specific here). 
  1664. Overall, PowerLisp 2.0 is much closer to the CLTL2 specification 
  1665. than any previous version of PowerLisp.
  1666.  
  1667. A serious bug which prevented PPC compiled code from 
  1668. working on certain Power Macs (related to the memory setup) 
  1669. has now been fixed. This generally caused a crash during startup 
  1670. on affected machines. The fix was released last summer as 
  1671. PowerLisp 1.2.1d. These changes are now included in PowerLisp 
  1672. 2.0.
  1673.  
  1674.  
  1675. New Features in PowerLisp 1.2
  1676.  
  1677. The most important new feature of PowerLisp 1.2 is native 
  1678. Power Mac execution and compilation. For 68k users, the new 
  1679. tagged pointer architecture allows much better handling of 
  1680. integers, which reduces memory requirements and improves 
  1681. speed. Future versions of PowerLisp should gain even more 
  1682. from this new architecture.
  1683.  
  1684. A number of bugs have been fixed, and new functions 
  1685. implemented. The most important bug fix has to do with floating 
  1686. point number comparisons, which now work correctly. My 
  1687. apologies to those of you who scratched your heads over this 
  1688. one. It was actually a one character typo in a routine called by all 
  1689. the comparison operators.
  1690.  
  1691. The open function pays attention for whether files are read-
  1692. only, write-only, etc. This mat cause some of your code to break 
  1693. if it relied on PowerLisp 1.1's default to read/write permission. 
  1694. Read-only is not the default, as per the Common Lisp standard.
  1695.  
  1696. Printing of symbols and strings now correctly pays attention to 
  1697. the *print-escape* variable.
  1698.  
  1699. The documentation function is enhanced for version 1.2. Asking 
  1700. for documentation for a Common Lisp symbol now 
  1701. automatically brings up the appropriate text from Guy Steele's 
  1702. book Common Lisp the Language (thanks to Digital Press for 
  1703. allowing electronic distribution). Also, this book as well as 
  1704. PowerLisp documentation can be browsed from a hierarchical 
  1705. Documentation menu.
  1706.  
  1707.  
  1708.  
  1709. Troubleshooting
  1710.  
  1711.  
  1712. PowerLisp Startup Process
  1713.  
  1714. When PowerLisp launches, it first boots the kernel, which sets 
  1715. up all the internal heaps and data structures, including 
  1716. initializing symbols in the symbol tables, and loading necessary 
  1717. code. Once the kernel is successfully started, the file 
  1718. stdlib.lisp is searched for in the Library folder, which is 
  1719. expected to be a subfolder of the folder the application was 
  1720. launched from. This file normally contains code which will allow 
  1721. compiled lisp files to be loaded (the kernel does not have this 
  1722. feature built in), and then proceeds to load all the file cl.lisp. 
  1723. This file loads a number of other startup files as well. Compiled 
  1724. versions of these files are searched for first (.fasl or .ppcl 
  1725. extension) but if these are not found the loader will attempt to 
  1726. load copies of these files with a .lisp extension. Any files with 
  1727. a .lisp extension will run interpretively, and therefore 
  1728. somewhat slower, than the compiled files.
  1729.  
  1730. If anything goes wrong during the startup process, the system 
  1731. will not be left in a stable state. It may appear to perform 
  1732. correctly, but will likely crash on the first evaluation error (the 
  1733. evaluator error handler gets set up relatively late in the boot 
  1734. process). Generally you will get some type of error message in 
  1735. the Worksheet if anything went wrong during startup.
  1736.  
  1737. A typical problem is that not enough memory is available to load 
  1738. all the modules that need to be loaded. If you get a message that 
  1739. says Can't copy compiled function this actually 
  1740. means you are low on memory. Other low memory messages are 
  1741. less cryptic.
  1742.  
  1743.  
  1744.  
  1745.  
  1746. What To Do If PowerLisp Will Not Run
  1747.  
  1748. Some users have reported that PowerLisp freezes during startup, 
  1749. giving them no error message. There was a known bug in 
  1750. PowerLisp 1.2, fixed in 2.0, which cause a crash during startup 
  1751. on Macs with virtual memory turned on (including 
  1752. RamDoubler) or Macs with >32 megs of RAM. A development 
  1753. fix (PowerLisp 1.2.1d) was released to fix this problem, but some 
  1754. users still seem to have problems. If you have problems running 
  1755. PowerLisp, here are some things to try.
  1756.  
  1757. •    Increase the amount of memory available. The minimum 
  1758. that is specified in the Get Info box may not be enough 
  1759. to start up on every Macintosh configuration. Increase this 
  1760. by one or two megabytes and try again. If you are then able 
  1761. to start PowerLisp, you can experiment with the value to get 
  1762. the right minimum for your system. If you are low on 
  1763. memory, try using RamDoubler (from Connectix) or 
  1764. Macintosh Virtual Memory (from the Memory Control 
  1765. Panel). It is not recommended that you run PowerLisp in a 
  1766. partition larger than the physical RAM in your system. If 
  1767. you try this, performance will probably not be good!
  1768.  
  1769. •    Remove the compiled libraries. If increasing memory 
  1770. doesn't help, you can try running interpretively. You do this 
  1771. by moving all the .fasl (on 68k) or .ppcl (on Power Mac) 
  1772. files from the library folder. Put them in a different folder for 
  1773. safekeeping. Then restart PowerLisp. Normally this will 
  1774. allow PowerLisp to run, although performance will be 
  1775. slower.
  1776.  
  1777. •    Run emulated on Power Mac. Another option, for Power 
  1778. Mac users, is to run PowerLisp in 68k emulated mode. You 
  1779. can do this by using ResEdit to edit a copy of PowerLisp 2.0. 
  1780. Do not modify your original. In ResEdit, open the PowerLisp 
  1781. 2.0 application. Delete the 'cfrg' resource. Save the 
  1782. application, and restart it. This will cause PowerLisp to run 
  1783. emulated, using the compiled .fasl 68k libraries. 
  1784. Performance may be better than running interpreted (above). 
  1785. If you try this, please do not redistribute this modified 
  1786. copy of PowerLisp.
  1787.  
  1788. •    Disable extensions. If none of the above works, try 
  1789. rebooting your Macintosh with the shift key held down. This 
  1790. will disable extensions. See if this allows you to run 
  1791. PowerLisp.
  1792.  
  1793. If none of the above works, please put together a mail message 
  1794. containing whatever information about your system you can, as 
  1795. well as the version of PowerLisp you are using, and send a 
  1796. message to PowerLisp@aol.com. We cannot guarantee we will 
  1797. be able to help non-registered users, but if at all possible we will 
  1798. try to contact you with some advice. In any case, your messages 
  1799. will help us track down problems and fix them in later releases.
  1800.  
  1801.  
  1802. Notes
  1803.  
  1804. I would like to thank my wife, Frances, for her assistance with 
  1805. this documentation and for her patience and encouragement. 
  1806.  
  1807. I would also like to thank Guy Steele Jr., whose books Common 
  1808. Lisp: The Language, both editions, are a constant source of 
  1809. assistance and amusement (in the most positive sense). 
  1810. PowerLisp 2.0 also includes the optimized backquote facility 
  1811. from the second edition, as well as some other functions from the 
  1812. book.
  1813.  
  1814. Jim Bisso has been a valuable resource to me and helped with 
  1815. PowerLisp development.
  1816.  
  1817. Peter Norvig's text Paradigms of Artificial Intelligence 
  1818. Programming: Case Studies in Common Lisp taught me a lot 
  1819. about the language and his many sample programs were useful 
  1820. in debugging the interpreter and compiler. I highly recommend 
  1821. it to anyone learning Common Lisp.
  1822.  
  1823. Acknowledgments to MIT for their Loop facility source code, 
  1824. which I have included with this package.
  1825.  
  1826. Acknowledgments to CMU for their Random facility source 
  1827. code, which I have included with this package.
  1828.  
  1829. Acknowledgments to Gregor Kiczales, Jim des Rivières, and 
  1830. Daniel G. Bobrow, for their excellent book The Art of the 
  1831. Metaobject Protocol. The source code from this book is the basis 
  1832. for  the PowerLisp 2.0 CLOS capability.
  1833.  
  1834. Thanks to Ken Long for his improved color icons, which are 
  1835. included in the released version of PowerLisp 1.2.
  1836.  
  1837. Thanks to MetroWerks, for building the best C++ programming 
  1838. environment I have ever used: CodeWarrior. The PowerLisp 
  1839. environment and kernel are compiled using CodeWarrior.
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.